export interface IPdroduct {
    id : number
    title : string
    price : number
    inventory : number
}

const _products: IPdroduct[] = [
    {id: 1, title: "IPAD 4 Mini", price: 500, inventory: 2},
    {id: 2, title: "Steam", price: 300, inventory: 10},
    {id: 3, title: "Pig lala", price: 400, inventory: 5}
]

export const getProducts = async () => {
    await wait(100)
    return _products
}

export const buyProducts = async () => {
    await wait(100)
    return Math.random()* 20 > 10
}

async function wait(delay:number) {
    return new Promise((resolve) => setTimeout(resolve,delay))
}